package socketmvc.client.config;

import socketmvc.core.config.IpConfigType;
import socketmvc.core.config.SocketMvcConfig;

public class WsIpConfig implements SocketMvcConfig.IpConfig {

    private final String host;
    private boolean enable = true;

    public WsIpConfig(String host) {
        this.host = host;
    }

    public void setEnable(boolean enable) {
        this.enable = enable;
    }
    /**
     * 获取ip配置是否启用
     *
     * @return 是否启用
     */
    @Override
    public boolean isEnable() {
        return enable;
    }

    /**
     * 获取ip配置协议类型
     *
     * @return 协议类型
     */
    @Override
    public IpConfigType getType() {
        return IpConfigType.WEB_SOCKET;
    }

    /**
     * 获取配置唯一标识
     *
     * @return 唯一标识
     */
    @Override
    public String getId() {
        return getHost();
    }

    /**
     * 获取绑定ip
     *
     * @return ip
     */
    @Override
    public String getHost(){
        return host;
    }

    /**
     * socket 端口
     *
     * @return 端口
     */
    @Override
    public int getPort() {
        throw new RuntimeException("客户端ip配置不支持设置port属性,请通过host设置端口");
    }

    /**
     * 获取socket ssl配置
     *
     * @return ssl配置
     */
    @Override
    public SocketMvcConfig.SSL getSsl() {
        throw new RuntimeException("客户端不需要配置ssl,使用ssl只需在host中声明为wss://协议即可");
    }
}
